﻿using System.Collections.Generic;
using System.Data;
using System.Linq;

namespace hCommand {
    /**
   *┌────────────────────────────────────────────────┐
   *│　描    述：LocSelect                                                    
   *│　作    者：sgj                                              
   *│　版    本：1.0                                              
   *│　创建时间：2021/9/8 16:59:49                        
   *└────────────────────────────────────────────────┘
   **/
    public class SingleLocSelect :LocSelect {
        public override CoreWhLoc moveSelect(CoreWhLoc src ,IDbConnection Connection ,IDbTransaction transaction) {
            List<CoreWhLoc> locList = CoreUtil.getLoc4SelectIn(src.areaId ,src.moveGroup ,Connection ,transaction);
            return select(locList ,src.goodsDiff);
        }

        public override bool canWork(long meId ,long beforeId ,List<long> relyTask) {
            BaseTask me = PathFacade.getTaskById(meId);
            BaseTask before = PathFacade.getTaskById(beforeId);
            if( me.className == before.className ) {
                return before.status >= 5;
            }
            return false;

        }
        public override CoreWhLoc select(List<CoreWhLoc> locList ,long goodDiff) {

            int len = locList.Count();
            for( int i = 0;i < len;i++ ) {
                CoreWhLoc shallow = locList[i];
                if( shallow.countStock == 0 ) {
                    return shallow;
                }
            }
            return null;

        }
    }
}
